/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JInternalFrameRecibirOFAD.java
 *
 * Created on Apr 4, 2010, 7:33:41 PM
 */

package tiendagui.internal;

import controller.ControllerRecibirOFAD;
import controller.utils.ControllerTable;
import controller.utils.ManagerTabla;
import javax.swing.JTable;
import model.ModelRecibirOFAD;

/**
 *
 * @author Jhonny
 */
public class JInternalFrameRecibirOFAD extends JInternalFrameImpl {

    private ManagerTabla managerTablaNuevo;
    private ManagerTabla managerTablaExistente;
    /** Creates new form JInternalFrameRecibirOFAD */
    public JInternalFrameRecibirOFAD(ModelRecibirOFAD model) {
        controller = new ControllerRecibirOFAD(this,model);
        initComponents();
        managerTablaNuevo = new ManagerTabla(tablaNuevos);
        managerTablaNuevo.setController((ControllerTable) controller);
        managerTablaExistente = new ManagerTabla(tablaExistentes);
        managerTablaExistente.setController((ControllerTable) controller);
    }


    public JTable getTable(){
        return this.tablaNuevos;
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labelNuevo = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaExistentes = new javax.swing.JTable();
        buttonCancelar = new javax.swing.JButton();
        buttonAceptar = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        tablaNuevos = new javax.swing.JTable();
        labelExistente = new javax.swing.JLabel();

        setClosable(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(tiendagui.TiendaGUIApp.class).getContext().getResourceMap(JInternalFrameRecibirOFAD.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        labelNuevo.setText(resourceMap.getString("labelNuevo.text")); // NOI18N
        labelNuevo.setName("labelNuevo"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        tablaExistentes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {new Integer(1), null, "Nombre 1", null, null},
                {new Integer(2), null, "Nombre 2", null, null},
                {new Integer(3), null, "Nombre 3", null, null},
                {null, null, "Nombre 4", null, null}
            },
            new String [] {
                "Referencia", "Stock", "Descripción", "Precio", "Oferta"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class, java.lang.Float.class, java.lang.Float.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaExistentes.setName("tablaExistentes"); // NOI18N
        jScrollPane1.setViewportView(tablaExistentes);

        buttonCancelar.setText(resourceMap.getString("buttonCancelar.text")); // NOI18N
        buttonCancelar.setName("buttonCancelar"); // NOI18N
        buttonCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCancelarActionPerformed(evt);
            }
        });

        buttonAceptar.setText(resourceMap.getString("buttonAceptar.text")); // NOI18N
        buttonAceptar.setName("buttonAceptar"); // NOI18N
        buttonAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonAceptarActionPerformed(evt);
            }
        });

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        tablaNuevos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, "Nombre 1", null, null, null},
                {null, "Nombre 2", null, null, null},
                {null, "Nombre 3", null, null, null},
                {null, "Nombre 4", null, null, null}
            },
            new String [] {
                "Referencia", "Nombre", "Precio", "Oferta", "Pto. Pedido"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.Float.class, java.lang.Float.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaNuevos.setName("tablaNuevos"); // NOI18N
        jScrollPane2.setViewportView(tablaNuevos);

        labelExistente.setText(resourceMap.getString("labelExistente.text")); // NOI18N
        labelExistente.setName("labelExistente"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(labelNuevo)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 284, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(buttonAceptar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addComponent(buttonCancelar))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
                    .addComponent(labelExistente))
                .addContainerGap())
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
                    .addContainerGap()))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelNuevo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 209, Short.MAX_VALUE)
                .addComponent(labelExistente)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonCancelar)
                    .addComponent(buttonAceptar))
                .addContainerGap())
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(41, 41, 41)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(293, Short.MAX_VALUE)))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-482)/2, (screenSize.height-533)/2, 482, 533);
    }// </editor-fold>//GEN-END:initComponents

    private void buttonCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelarActionPerformed
        controller.cerrar();
    }//GEN-LAST:event_buttonCancelarActionPerformed

    private void buttonAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAceptarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_buttonAceptarActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonAceptar;
    private javax.swing.JButton buttonCancelar;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel labelExistente;
    private javax.swing.JLabel labelNuevo;
    private javax.swing.JTable tablaExistentes;
    private javax.swing.JTable tablaNuevos;
    // End of variables declaration//GEN-END:variables

}
